from google.appengine.ext import db
from google.appengine.ext import search  

##################################################################################
#                                                                                #
#                       Models                                                   #
#                                                                                #
##################################################################################

class CustomUser(db.Model):
  name = db.StringProperty()
  url = db.StringProperty()
  user = db.UserProperty()
  role = db.StringProperty()



class Genre(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  pub_date=db.DateTimeProperty(auto_now=True, auto_now_add=True)



class Role(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  description=db.TextProperty()
  pub_date=db.DateTimeProperty(auto_now=True, auto_now_add=True)



class Person(search.SearchableModel):
  name = db.StringProperty()
  url = db.StringProperty()
  pub_date=db.DateTimeProperty(auto_now=True, auto_now_add=True)



class Film(search.SearchableModel):
  title = db.StringProperty()
  url = db.StringProperty()
  originaltitle = db.StringProperty()
  director = db.ReferenceProperty(Person)
  casting = db.StringListProperty()
  castingurl = db.StringListProperty()
  image = db.StringProperty()
  year = db.IntegerProperty(default=1900)
  genres = db.StringListProperty()
  genresurl = db.StringListProperty()
  genre = db.ReferenceProperty(Genre)
  plot = db.TextProperty()
  customuser = db.ReferenceProperty(CustomUser)
  name = db.StringProperty()
  originalname = db.StringProperty()
  director = db.ReferenceProperty(Person)
  userurl = db.StringProperty()
  pub_date = db.DateTimeProperty(auto_now_add=True)
  active = db.BooleanProperty(default=True)
  autonumeric = db.IntegerProperty(default=-1)



class PersonxFilm(search.SearchableModel):
  person = db.ReferenceProperty(Person)
  film = db.ReferenceProperty(Film)



class File(db.Model):
  code=db.StringProperty()
  bytes_content=db.BlobProperty()
  authorname=db.StringProperty()
  authorurl=db.StringProperty()
  mime=db.StringProperty()
  extension=db.StringProperty()
  size=db.IntegerProperty()
  width=db.IntegerProperty()
  height=db.IntegerProperty()
  status=db.StringProperty()
  type = db.StringProperty()
  service = db.StringProperty()
  imagetype = db.StringProperty(default='normal')
  pub_date=db.DateTimeProperty(auto_now_add=True)
  filekey=db.StringProperty()



class Language(search.SearchableModel):
  name = db.StringProperty(default = '')
  url = db.StringProperty(default = '')



class TermType(search.SearchableModel):
  name = db.StringProperty(default = '')
  url = db.StringProperty(default = '')



class Tag(search.SearchableModel):
  name = db.StringProperty(default = '')
  url = db.StringProperty(default = '')
  language = db.ReferenceProperty(Language)
  letters = db.StringListProperty()
  autonumeric = db.IntegerProperty(default = 0)
  pub_date=db.DateTimeProperty(auto_now_add = True)
  
 
class Term(search.SearchableModel):
  word = db.StringProperty(default = '')
  prefix = db.StringProperty(default = '')
  url = db.StringProperty(default = '')
  level = db.StringProperty(default = 'C1')
  translate = db.StringProperty(default = '')
  translate2 = db.StringProperty(default = '')
  translate3 = db.StringProperty(default = '')
  language = db.ReferenceProperty(Language)
  termtype = db.ReferenceProperty(TermType)
  pub_date = db.DateTimeProperty(auto_now_add = True)
  tags = db.StringListProperty()
  attributes = db.StringListProperty()
  autonumeric = db.IntegerProperty(default=-1)
  fav1 = db.BooleanProperty(default=False)
  fav2 = db.BooleanProperty(default=False)




class Pagination(db.Model):
  name = db.StringProperty()
  first = db.StringProperty()
  last = db.StringProperty()
  pub_date = db.DateTimeProperty(auto_now = True)

class Configuration(db.Model):
  name = db.StringProperty()
  value = db.StringProperty()
  blocked = db.BooleanProperty(default=False)
  pub_date = db.DateTimeProperty(auto_now = True)

